<template>
  <div class="header">
    <h1>我是头部</h1>
    <p>count的值是{{ this.$store.state.count }}</p>
    <p>价格是{{ price }}</p>

    <button @click="increment">累加count的值</button>
    <button @click="incrementN({n:3})">count每次加n</button>
  </div>
</template>

<script>
import { mapMutations, mapState } from "vuex";

export default {
  name: "Header",
  computed: {
    ...mapState(["count", "price"]),
  },
  methods: {
    ...mapMutations(['increment','incrementN'])
    // increment() {
    //   this.$store.commit("increment");
    // },
    // incrementN(n) {
    //   this.$store.commit("incrementN", { n });
    // },
  },
};
</script>

<style scoped>
.header {
  margin: 30px;
  background: yellowgreen;
}
</style>